﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<brjostagjof.Models.New>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Fréttir 
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    
    <% if (Page.User.IsInRole("Administrators") || Page.User.IsInRole("Specialists"))
       { %>
        <a href="/Home/AddNews" class="linksWhite"> Ný frétt </a> 
     <%} %>
         <% if (Page.User.IsInRole("Administrators"))
            { %>
        <a href="/Home/AddNewsCategory/" class="linksWhite"> Nýr fréttaflokkur </a>
        <% } %>
    <a href="/Home/Index/" class="linksWhite">Til baka á forsíðu</a>
    <h2>Fréttaflokkar:</h2>
    <ul>
        <% var categories = brjostagjof.Controllers.HomeController.GetNewsCategories();
        foreach (var category in categories)
        { %>
            <li>
            <a href="/Home/GetNewsByCategoryID/<%: category.ID %>"><%: category.name%></a>
            </li>
        <% } %>
    </ul>

        <h2>Nýjustu fréttir:</h2>

        <% var latestNews = brjostagjof.Controllers.HomeController.Get10News();
        foreach (var item in latestNews)
        { %>
        <div class="entry">
        <div class="entry-bgtop">
        <div class="entry-bgbtm">
            <h2 class="title"><a href="<%: item.ArticleBase.link %><%: item.articleBaseID %>"><%: item.ArticleBase.InformationBase.headline%></a></h2>
            <p class="meta">Höfundur: <a href="../../MySite/ViewUserByID/<%:item.ArticleBase.User.ID  %>"><%: item.ArticleBase.User.name%></a>,  <%: item.ArticleBase.InformationBase.date%> 
	            &nbsp;&bull;&nbsp;
                <%  int count = brjostagjof.Controllers.HomeController.GetCommentsCountByArticleBaseID(item.articleBaseID); %>
                Umsagnir  (<%: count %>) &nbsp;&bull;&nbsp;
                <a href="/Home/GetNewsByCategoryID/<%: item.ArticleBase.ArticleCategory.ID %>" class="permalink"> <%: item.ArticleBase.ArticleCategory.name %></a>  
                &nbsp;&bull;&nbsp;
                <a href="<%: item.ArticleBase.link %><%: item.articleBaseID %>" class="permalink">Öll frétt</a></p>
        </div>
        </div>
        </div>
        <%  } %>



            <% int page = 1; %>
            <% for (int i = page-4; i < page+5; i++)
            {%>
                <% if(i == 0)
                   { %>
                   <a href="/Home/Frettir/">1</a>
                   <% }%>
                 <% if ((i > 0) && (i <= ((brjostagjof.Controllers.HomeController.GetAllNewsCount())/10)))
                { %>
                    <a href="/Home/Get10NewsByPageID/<%: i %>"><%: i + 1 %></a>
               <% }%>
           <% } %>
           <a href="/Home/Get10NewsByPageID/1" class="linksWhite">Eldri fréttir</a>

</asp:Content>